/*	This file is part of LSAC.

	LSAC is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.

	LSAC is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with LSAC.  If not, see <http://www.gnu.org/licenses/>.

	Copyright (c) 2010 LEPESME "Jiboo" Jean-Baptiste
*/

#include "cInstPrint.h"
#include "cCPPUtils.h"
#include "lsac.h"

cInstPrint::cInstPrint(cLocation pLocation, cBlock *pBlock, cExpression *pValue)
	: cInstruction(pLocation, pBlock, "")
{
	this->dValue = pValue;
}

cInstPrint::~cInstPrint()
{
	delete this->dValue;
}

void cInstPrint::print(int pLevel)
{
	PRINT_LOG("cInstPrint " << this);
	PRINT_LOG("(");
	this->dValue->print(pLevel + 1);
	PRINT_LOG(")");
}

void cInstPrint::validate(cSemContext *pContext)
{
	this->dValue->validate(pContext);
}

void cInstPrint::genCode(ostream &pStream)
{
	pStream << "std::cout << ";
	this->dValue->genCode(pStream);
	pStream << " << std::endl;" << endl;
}
